/** 顶尖猎人,按键设定为:单发a,单发b,单发c

  By setycyas @2025-11-13
*/

/* 全局设定
*/ 
;导入自定义函数库
#Include "..\Class\OrderMap.2.ahk"
#Include "..\Class\MyFuns.2.ahk"
;导入宏相关函数和UI
#Include "..\Class\FaceDetector.2.ahk"
#Include "..\Class\CommonMacro.2.ahk"
#Include "..\Class\CommonUI.2.ahk"
#Include "..\Class\MyEmu.2.ahk"
#Include "..\Class\MySecondCounter.2.ahk"

#Warn
#MaxThreadsPerHotkey 1
SetWorkingDir(A_ScriptDir)

SendMode("Input")

/* 制作顶尖猎人的宏类
*/ class TophuntrMacro extends CommonMacro {

  /* 新增的宏函数
  */
  _前下前A(key){
    local face := this._face.face()
    Myfuns.press(face, 40)
    sleep(40)
    Myfuns.keyDown("down")
    sleep(50)
    Myfuns.keyDown(face)
    sleep(40)
    Myfuns.keyUp("down")
    this._press(1)
    Myfuns.keyUp(face)
  }
  _下前A(key){
    local face := this._face.face()
    Myfuns.keyDown("down")
    sleep(50)
    Myfuns.keyDown(face)
    sleep(40)
    Myfuns.keyUp("down")
    this._press(1)
    Myfuns.keyUp(face)
  }
  _下前B(key){
    local face := this._face.face()
    Myfuns.keyDown("down")
    sleep(50)
    Myfuns.keyDown(face)
    sleep(40)
    Myfuns.keyUp("down")
    this._press(2)
    Myfuns.keyUp(face)
  }
  _上前A(key){
    local face := this._face.face()
    Myfuns.keyDown("up")
    sleep(50)
    Myfuns.keyDown(face)
    sleep(40)
    Myfuns.keyUp("up")
    this._press(1)
    Myfuns.keyUp(face)
  }
  _抓人(key){
    this._down(1)
    sleep(300)
    this._up(1)
  }
  _下上B(key){
    Myfuns.press("down", 350)
    sleep(50)
    Myfuns.keyDown("up")
    sleep(30)
    this._press(2)
    Myfuns.keyUp("up")
  }

  /* 重载宏接口
  */
  _setMacro(){
    local obm := ObjBindMethod ;函数名简写,制作对象绑定函数
    ;制作宏相关Map
    this.macroMap := OrderMap()
    this.macroMap["抓人"] := obm(this, "_抓人")
    this.macroMap["上前A"] := obm(this, "_上前A")
    this.macroMap["前下前A"] := obm(this, "_前下前A")
    this.macroMap["下前A"] := obm(this, "_下前A")
    this.macroMap["下前B"] := obm(this, "_下前B")
    this.macroMap["下上B"] := obm(this, "_下上B")
    this.macroArr := this.macroMap.getKeys()
  }

}

/* 制作顶尖猎人专用UI
*/
class TophuntrUI extends CommonUI {

  DEFAULT_HOTKEYS := "~d"
  EXE_ARRAY := [MyEmu.MAME, MyEmu.XZONE]
  HOTKEY_NUM := 8

  /* 构造函数
  */
  __New(macro){
    super.__New("顶尖猎人", macro)
    this._preset := OrderMap([
    	"默认", 
      ["抓人", "上前A", "下上B", "前下前A", "下前B"],
      "测试1", 
      ["抓人", "上前A", "下前A", "下前B"],
      "测试2", 
      ["抓人", "前下前A", "下前A", "下前B"],
    ])
    this._macro.UI := this ;绑定UI
  }
  
}

/* 运行当前脚本
*/ if (A_ScriptName == "顶尖猎人.2.ahk") {
  face := FaceDetector() ;方向检测对象
  macro := TophuntrMacro(face, ["q","d"]) ;宏对象,有界面时第二个参数可以随便写但长度不要小于2
  ;新建界面并设定
  ui := TophuntrUI(macro)
  ui.setup()
  ui._gameKeyEdit.Text := "x,d,space"
  ui._exeComboBox.Choose(MyEmu.MAME)
  ;ui._exeComboBox.Choose(MyEmu.XZONE)
  ui._hotkeyEdit.Text := "s,a,w,e,f"
  ui._testEdit.Text := "50,50,30,30"
  ui._myGui.opt("+AlwaysOnTop")
  ui._myGui.show("x1100 y330")
  ui.readPresetMenu("默认")
}